const app = getApp()
var a = -1;
var b = -1;
var c = -1;
var d = -1;
var e = -1;

Page({
  data: {
    
    select: false,
    tihuoWay: '佛山',
    // scrollTop: 2000,

    //区间
    leftMin: 0,
    leftMax: 6,
    rightMin: 0,
    rightMax: 6,
    leftValue: 0,
    rightValue: 6,
    scrollTop:0

  },


  bindShowMsg() {
    this.setData({
      select: !this.data.select
    })
  },
  mySelect(e) {
    var name = e.currentTarget.dataset.name
    this.setData({
      tihuoWay: name,
      select: false
    })
  },
// xialai
changeBoxBtn: function (e) {
    // console.log(e.target.dataset.num)
    var num = e.target.dataset.num;
    var states = null;
    if (num == 0) {
      states = 0;
      a += 1;
      b = -1;
      c = -1;
      d = -1;
      if (a % 2 == 1) {
        states = 6;
      }
    } else if (num == 1) {
      states = 1;
      a = -1;
      b += 1;
      c = -1;
      d = -1;
      if (b % 2 == 1) {
        states = 6;
      }
    } else if (num == 2) {
      states = 2;
      a = -1;
      b = -1;
      c += 1;
      d = -1;
      if (c % 2 == 1) {
        states = 6;
      }
    } else if (num == 3) {
      states = 3;
      a = -1;
      b = -1;
      c = -1;
      d += 1;
      if (d % 2 == 1) {
        states = 6;
      }
    } else if (num == 4) {
      states = 4;
      a = -1;
      b = -1;
      c = -1;
      d = -1;
      e += 1;
      if (e % 2 == 1) {
        states = 6;
      }
    }
    // console.log(states)

    this.setData({
      states: states
    })
  },




//区间

  //价格slider滑动
  leftSchange: function (e) {
    var that = this
    that.setData({
      isQuery: false
    })
    var value = e.detail.value
    if (value == that.data.rightValue) {
      if (that.data.rightValue == 6) value--
      else value++
    }
    that.setData({
      leftValue: value
    })
    if (value < that.data.rightValue) {
      var bg_price = that.data.priceList[value].slice(1)
      var end_price = that.data.priceList[that.data.rightValue].slice(1)
    }
    else {
      var end_price = that.data.priceList[value].slice(1)
      var bg_price = that.data.priceList[that.data.rightValue].slice(1)
    }
    list['bg_price'] = bg_price
    list['end_price'] = end_price
    wx.setStorageSync("priceList", { bg_price: value, end_price: that.data.leftValue })
    setTimeout(function () {
      wxb.Post('/api/minsu.index/index', list, function (data) {
        console.log(list, "价格slider")
        console.log(data)
        that.setData({
          isQuery: true
        })
        if (data.length != 0) {
          that.setData({
            result: data.num + '套',
          })
        }
        else {
          that.setData({
            result: '0套',
          })
        }
      })
    }, 700)
  },
  //右边
  rightSchange: function (e) {
    var that = this
    that.setData({
      isQuery: false
    })
    var value = e.detail.value
    if (value == that.data.leftValue) {
      if (that.data.leftValue == 6) value--
      else value++
    }
    that.setData({
      rightValue: value
    })
    if (value < that.data.leftValue) {
      var bg_price = that.data.priceList[value].slice(1)
      var end_price = that.data.priceList[that.data.leftValue].slice(1)
    }
    else {
      var end_price = that.data.priceList[value].slice(1)
      var bg_price = that.data.priceList[that.data.leftValue].slice(1)
    }
    list['bg_price'] = bg_price
    list['end_price'] = end_price
    wx.setStorageSync("priceList", { bg_price: value, end_price: that.data.leftValue })
    setTimeout(function () {
      wxb.Post('/api/minsu.index/index', list, function (data) {
        console.log(list, "价格slider")
        console.log(data)
        that.setData({
          isQuery: true
        })
        if (data.length != 0) {
          that.setData({
            result: data.num + '套',
          })
        }
        else {
          that.setData({
            result: '0套',
          })
        }
      })
    }, 700)
  },




  //滚

  click100:function(e){

    // this.setData({
    //   scrollTop: 100
    // })
      console.log(e);

  },

  onLoad: function (options) {
    // wx.pageScrollTo({
    //   scrollTop: 100
    // })
  },

  getScrollOffset() {
    wx.createSelectorQuery().selectViewport().scrollOffset(function (res) {
      res.id      // 节点的ID
      res.dataset // 节点的dataset
      res.scrollLeft // 节点的水平滚动位置
      res.scrollTop  // 节点的竖直滚动位置
    }).exec()
  }



})
